# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=golang-gopkg-pipe.v2
pkgver=0.0.20140414
_commit=3c2ca4d525447ec8b2f606a6974f9c9f40831f26
pkgrel=1
pkgdesc='Package pipe implements unix-like pipelines for Go'
arch=('any')
url="https://github.com/go-pipe/pipe/tree/v2"
license=('BSD')
depends=('go')
checkdepends=('golang-gopkg-check.v1')
source=("$pkgname-$_commit.tar.gz::https://github.com/go-pipe/pipe/archive/$_commit.tar.gz")
sha512sums=('35737617793948f683b60f5297c4df73002be1812fc25ddba7180d5045e954906e60053bb610b4985a4d857acaa2658c587954f148dba6fad766990512d46306')

check() {
  export GO111MODULE=off
  export GOPATH="$srcdir/build:/usr/share/gocode"
  mkdir -p "$srcdir"/build/src/gopkg.in
  cp -a "$srcdir"/pipe-$_commit "$srcdir"/build/src/gopkg.in/pipe.v2
  cd "$srcdir"/build/src/gopkg.in/pipe.v2
  # https://github.com/go-pipe/pipe/issues/6
  go test -v $(go list ./...) || echo "Tests failed"
}

package() {
  mkdir -p "$pkgdir"/usr/share/gocode/src/gopkg.in
  cp -a "$srcdir"/pipe-$_commit "$pkgdir"/usr/share/gocode/src/gopkg.in/pipe.v2

  install -Dm644 pipe-$_commit/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
